﻿@model Data.DBModels.Category
@using Utilities;

@if (Model != null)
{
    

        <div>@Model.Name</div>

        @Ajax.ActionLink("edit", "EditPopUp", "Category",
        new { id = @Model.Id },
        new AjaxOptions() { HttpMethod = "Get", InsertionMode = InsertionMode.Replace, UpdateTargetId = Model.Id.ToString("N")+"popup" })


        @Ajax.ActionLink("delete", "Delete", "Category",
        new { id = @Model.Id },
                new AjaxOptions() { HttpMethod = "Post", Confirm = "Are you sure you wish to delete this website?", InsertionMode = InsertionMode.Replace, UpdateTargetId = "displayAllCategories" })

        <div id="@Html.Raw(Model.Id.ToString("N")+"popup")"></div>




        @*create a new website under the category*@

        @Ajax.ActionLink("Create", "EditPopUp", "Website",
        new { id = Guid.Empty, categoryId=Model.Id },
        new AjaxOptions() { HttpMethod = "Get", InsertionMode = InsertionMode.Replace, UpdateTargetId = @Model.Id.ToString("N") })
        @*@using (Ajax.BeginForm("Search", new AjaxOptions{    HttpMethod = "Post"}))
    {
        <input type="text" name="q" />
        <button type="submit" value="Search">Search</button>
    }*@
            <div id="@Model.Id.ToString("N")"></div>

            <ul class="noListStyle">
                @if (Model.Websites.me_IsValid())
                {
                    foreach (var website in Model.Websites)
                    {
                    <li class="websiteItem" id="@website.Id.ToString()">
                        @Html.Partial("_Website", website)
                    </li>
                    }
                }

            </ul>
        
}
